package com.jyw.business.de.domain.vo.web;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.jyw.business.de.domain.DeDemandAnalyze;
import com.jyw.common.annotation.Conversion;
import com.jyw.common.annotation.Excel;
import com.jyw.common.constant.SysDictTypeConstant;
import com.jyw.common.enums.ConversionType;
import com.jyw.common.utils.bean.BeanUtils;
import com.jyw.system.domain.vo.SimpleFileVo;
import com.jyw.system.utils.FileUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.FieldNameConstants;

import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 需求-需求分析对象 de_demand_analyze
 * 
 * @author ruoyi
 * @date 2024-02-19
 */
@Data
@ApiModel("需求分析详情实体")
@FieldNameConstants
@NoArgsConstructor
public class DemandAnalyzeVO
{
    private static final long serialVersionUID = 1L;

    /** 主键 */
    @ApiModelProperty("主键")
    private Long id;

    /** 需求分析人 */
    @ApiModelProperty("需求分析人")
    @Conversion(value = ConversionType.USER,name = Fields.analyzeUserName)
    private List<Long> analyzeUser;

    @ApiModelProperty("需求分析人名称")
    private List<String> analyzeUserName;

    /** 需求是否可行 1是 0否 */
    @ApiModelProperty("需求是否可行 1是 0否")
    private Integer demandFeasible;

    /** 需求是否必要 1必要 0不必要 */
    @ApiModelProperty("需求是否必要 1必要 0不必要")
    private Integer demandRequired;

    /** 涉及系统 */
    @ApiModelProperty("涉及系统")
    @Conversion(value = ConversionType.DICT,dictType = SysDictTypeConstant.OBS_ABOUT_SYSTEM)
    private List<String> analyzeSystem;

    @ApiModelProperty("涉及系统名称")
    private List<String> analyzeSystemToName;

    /** 分析情况说明 */
    @ApiModelProperty("分析情况说明")
    private String analyzeRemark;

    /** 分析附件 */
    @ApiModelProperty("分析附件")
    private List<SimpleFileVo> analyzeEnclosure;

    /** 创建人 */
    @ApiModelProperty("创建人")
    @Conversion(value = ConversionType.USER,name = Fields.createUserName)
    private Long createUser;

    /** 创建人 */
    @ApiModelProperty("创建人名称")
    private String createUserName;

    /** 需求分析时间 */
    @ApiModelProperty("需求分析时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    public DemandAnalyzeVO(DeDemandAnalyze analyze) {
        BeanUtils.copyProperties(analyze,this);
        setAnalyzeEnclosure(FileUtils.IdToFile(analyze.getAnalyzeEnclosure()));
        setAnalyzeUser(Arrays.asList(analyze.getAnalyzeUser().split(",")).stream().map(data->Long.valueOf(data)).collect(Collectors.toList()));
        setAnalyzeSystem(Arrays.asList(analyze.getAnalyzeSystem().split(",")));
    }
}
